#!/bin/sh

set -eux

INSTALL_DIR="$JIAPKG_INSTALL_DIR"
JOBS="$JIAPKG_JOBS"
JIAPKG="$JIAPKG_EXE"

jiapkg_build() {
	# Tell aclocal where to find libtool.m4 in package of libtool.
	ACLOCAL_PATH="$($JIAPKG info --install-dir libtool)/share/aclocal"
	export ACLOCAL_PATH

	./autogen.sh
	./configure --prefix="$INSTALL_DIR"
	make -j"$JOBS"
}

jiapkg_install() {
	make install
}

case "$1" in
build) jiapkg_build ;;
install) jiapkg_install ;;
esac
